package com.test.clyq.serviceImpl;

import java.util.List;

import com.test.clyq.dao.EntityItemDao;
import com.test.clyq.entity.EntityItem;
import com.test.clyq.entity.Users;
import com.test.clyq.service.EntityItemService;
import com.test.service.impl.BaseManager;
import com.test.util.Pagination;

/**
 * EntityItemServiceImpl. <br>
 * 内容信息管理.
 * <p>
 * Copyright: Copyright (c) 2010-4-18 下午03:44:59
 * <p>
 * Company: 北京宽连十方数字技术有限公司
 * <p>
 * Author: liuxl@c-platform.com
 * <p>
 * Version: 1.0
 * <p>
 */
@SuppressWarnings("unchecked")
public class EntityItemServiceImpl extends BaseManager implements EntityItemService {

	private EntityItemDao entityItemDao;

	public void addEntityItem(EntityItem entityitem, Users user) {
		this.entityItemDao.addEntityItem(entityitem, user);
	}

	/**
	 * 批量新增内容信息
	 * 
	 * @param list
	 *            内容实例列表
	 * @param user
	 *            用户实例
	 */
	public void addBAtch(List list, Users user) {
		entityItemDao.addBAtch(list, user);
	}

	public boolean delEntityItemById(Long id, Users user) {
		return this.entityItemDao.delEntityItemById(id, user);
	}

	public List<EntityItem> getAllEntityItems() {
		return entityItemDao.getAllEntityItems();
	}

	/**
	 * 文章code
	 * 
	 * @return
	 */
	public String getEntityCode(Long categoryId) {
		return entityItemDao.getEntityCode(categoryId);
	}

	/***************************************************************************
	 * 根据栏目ID 或 父ID获取文章
	 * 
	 * @param categoryId
	 * @param pagination
	 * @param where
	 * @param order
	 * @return
	 */
	public List<EntityItem> getEntityItemByCategoryId(Long categoryId, Pagination pagination, String where, String order) {
		// String whereString = setWhereOr(where, "and", "or");
		// String orderString = setOrder(order);
		return entityItemDao.getEntityItemByCategoryId(categoryId, pagination, where, order);
	}

	public EntityItem getEntityItemById(Long id) {
		return this.entityItemDao.getEntityItemById(id);
	}

	public List<EntityItem> getEntityItemListByCategoryId(Long categoryId, Pagination pagination) {
		return entityItemDao.getEntityItemListByCategoryId(categoryId, pagination);
	}

	public List<EntityItem> getEntityItemListByCategoryId(Long categoryId, Pagination pagination, List<String> where, List<String> orders) {
		String whereString = setWhere(where);
		String orderString = setOrder(orders);
		return this.entityItemDao.getEntityItemListByCategoryId(categoryId, pagination, whereString, orderString);
	}

	public List<EntityItem> getEntityItemListByKeyWord(String keyword, Pagination pagination) {
		return entityItemDao.getEntityItemListByKeyWord(keyword, pagination);
	}

	public List<EntityItem> getEntityItemListByParentCategoryId(Long categoryId, Pagination pagination, List<String> where, List<String> orders) {
		String whereString = setWhere(where);
		String orderString = setOrder(orders);
		return this.entityItemDao.getEntityItemListByParentCategoryId(categoryId, pagination, whereString, orderString);
	}

	public List<EntityItem> getEntityItemListForJournals(Long categoryId, Pagination pagination) {
		return this.entityItemDao.getEntityItemListForJournals(categoryId, pagination);
	}

	/**
	 * 根据网站ID获得回收站信息列表（分页使用）
	 * 
	 * @return 回收站信息列表结果集合
	 */
	public List<EntityItem> getRecycleBinListByWebsiteId(Pagination pagination) {
		return entityItemDao.getRecycleBinListByWebsiteId(pagination);
	}

	public List<EntityItem> getRelateList(Long entityItemId) {
		return this.entityItemDao.getRelateList(entityItemId);
	}

	public void merge(EntityItem entityitem, Users user) {
		entityItemDao.merge(entityitem, user);
	}

	public void saveOrUpdate(EntityItem entityitem, Users user) {
		this.entityItemDao.saveOrUpdate(entityitem, user);
	}

	public void setEntityItemDao(EntityItemDao entityItemDao) {
		this.entityItemDao = entityItemDao;
	}

	public EntityItem getEntityItemByTaoBaoId(String taobaoId) {
		return this.entityItemDao.getEntityItemByTaoBaoId(taobaoId);
	}
}
